#pragma once

#include <windows.h>
#include <gl\gl.h>
#include <gl\glu.h>

#include <vector>

#include "..\common\headers\IRenderable.h"
#include "..\Sgm\Geometry.h"
#include "Mesh.h"
#include <FileHolder.h>
//#include "TCBVec3Interpolator.h"
//#include "TCBRotInterpolator.h"
//#include "TCBFloatInterpolator.h"
#include "TcbKey.h"
#include "TCBKeyInterpolator.h"
#include "IAnimatable.h"

class Animation : public IRenderable
{
private:
	int id;
	float itm[16];
	IRenderable *model;
	IAnimatable *animatable;

	std::vector<Animation*> subAnims;

	static void LoadPosition(Animation *anim, FileHolder *fh);
	static void LoadRotation(Animation *anim, FileHolder *fh);
	static void LoadScale(Animation *anim, FileHolder *fh);
	static void LoadRoll(Animation *anim, FileHolder *fh);
	static Animation * LoadAnimation(Animation *parent, FileHolder *fh);

	float time;
	float animatablesTime;
	TCBKeyInterpolator *tcbKeyInterpolator;

public:
	Animation(int id, IRenderable *model);
	static Animation * LoadFromFile(const char *filename);

	void AttachAnimatable(IAnimatable *animatable);
	void AttachAnimatable(IAnimatable **animatables, int count);

	void Process(float ms);
	void ProcessAnimatables(float ms);
	void Render();
};
